package com.lz.gmall.product.controller;

import com.lz.gmall.common.result.Result;
import com.lz.gmall.common.result.ResultCodeEnum;
import com.lz.gmall.product.entity.BaseCategory1;
import com.lz.gmall.product.service.BaseCategory1Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
@Api(tags = "一级产品")
//@CrossOrigin
public class BaseCategory1Controller {

    @Autowired
    private BaseCategory1Service baseCategory1Service;

    /**
     * 获取产品列表的一级分类
     * @return 一级分类集合
     */
    @GetMapping("/getCategory1")
    @ApiOperation("获取产品的一级分类")
    public Result<List<BaseCategory1>> findAllBaseCategory1(){
        List<BaseCategory1> list = baseCategory1Service.list();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }
}
